/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ucm;

import java.sql.ResultSet;
import sql.Select;

/**
 *
 * @author 马凯
 */
public class BasicInfo_UC {
    private static BasicInfo_UC biuc;
    private String receive;
    private String output = "";
    
    public static BasicInfo_UC getInstance(String receive){
        if(biuc==null){
            biuc = new BasicInfo_UC();
            biuc.receive = receive;
        }
        else
        {
            biuc.receive = receive;
        }
        return biuc;
    }
    
    public String run(){
        String[] str = receive.split(";");
        String cid = str[0];
        String psw = str[1];
        String query = "SELECT roll.name,roll.id FROM roll,rfid WHERE roll.card_id='" + cid + "' AND rfid.cid='" + cid+ "' AND rfid.password='"+psw+"';";
        ResultSet rs = Select.getInstance().selectValue(query);
        try {
            if(rs.next()){
                return output = "Y;"+rs.getString("id")+";"+rs.getString("name")+";08";
            }
        }catch(Exception e){e.printStackTrace();}
        return output = "N"+";08";
    }
}

